/*
 *
 *  Crypto plugin API.
 *
 *  This file initially created by Google, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef __CONNMAN_CRYPTO_H
#define __CONNMAN_CRYPTO_H

#include <connman/profile.h>
#include <glib.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * SECTION:crypto
 * @title: Crypto primitives
 * @short_description: Functions for registering crypto modules
 */

#define CONNMAN_CRYPTO_PRIORITY_LOW      -100
#define CONNMAN_CRYPTO_PRIORITY_DEFAULT     0
#define CONNMAN_CRYPTO_PRIORITY_HIGH      100

struct connman_crypto {
        const char *name;
        int priority;
        char *(*encrypt_keyvalue) (const char *key, const char *value);
        char *(*decrypt_keyvalue) (const char *key, const char *value);

        /*
         * The prefix is the module name + ':', and is used a prefix for
         * the encrypted value when it is written to a KeyFile.  Both
         * prefix and prefix_size are computed from the module name when it
         * is registered, you should not populate them on your own.
         */
        char *prefix;
        gsize prefix_size;
};

int connman_crypto_register(struct connman_crypto *crypto);
void connman_crypto_unregister(struct connman_crypto *crypto);

#ifdef __cplusplus
}
#endif

#endif /* __CONNMAN_CRYPTO_H */
